package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WorkPatentWinners;
import com.ruoyi.system.service.IWorkPatentWinnersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 著作完成人
Controller
 * 
 * @author ruoyi
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/work/patentWinners")
public class WorkPatentWinnersController extends BaseController
{
    @Autowired
    private IWorkPatentWinnersService workPatentWinnersService;

    /**
     * 查询著作完成人
列表
     */
    @PreAuthorize("@ss.hasPermi('work:patentWinners:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkPatentWinners workPatentWinners)
    {
        startPage();
        List<WorkPatentWinners> list = workPatentWinnersService.selectWorkPatentWinnersList(workPatentWinners);
        return getDataTable(list);
    }

    /**
     * 导出著作完成人
列表
     */
    @PreAuthorize("@ss.hasPermi('work:patentWinners:export')")
    @Log(title = "著作完成人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkPatentWinners workPatentWinners)
    {
        List<WorkPatentWinners> list = workPatentWinnersService.selectWorkPatentWinnersList(workPatentWinners);
        ExcelUtil<WorkPatentWinners> util = new ExcelUtil<WorkPatentWinners>(WorkPatentWinners.class);
        util.exportExcel(response, list, "著作完成人数据");
    }

    /**
     * 获取著作完成人
详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:patentWinners:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(workPatentWinnersService.selectWorkPatentWinnersById(id));
    }

    /**
     * 新增著作完成人

     */
    @PreAuthorize("@ss.hasPermi('work:patentWinners:add')")
    @Log(title = "著作完成人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkPatentWinners workPatentWinners)
    {
        return toAjax(workPatentWinnersService.insertWorkPatentWinners(workPatentWinners));
    }

    /**
     * 修改著作完成人

     */
    @PreAuthorize("@ss.hasPermi('work:patentWinners:edit')")
    @Log(title = "著作完成人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkPatentWinners workPatentWinners)
    {
        return toAjax(workPatentWinnersService.updateWorkPatentWinners(workPatentWinners));
    }

    /**
     * 删除著作完成人

     */
    @PreAuthorize("@ss.hasPermi('work:patentWinners:remove')")
    @Log(title = "著作完成人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(workPatentWinnersService.deleteWorkPatentWinnersByIds(ids));
    }
}
